package course;

public class Student extends People {
    private Course[] StudentCourse;

    public Student() {}

    public Student(int ID, String Name, String Gender) {
        this.ID = ID;
        this.Name = Name;
        this.Gender = Gender;
        StudentCourse=new Course[3];
    }

    public boolean choseCourse(Course course) {
        boolean flag = false;
        for (int i = 0; i < this.StudentCourse.length; i++) {
            if (StudentCourse[i] == null) {
                StudentCourse[i] = course;
                flag = true;
                break;
            }
        }
        return flag;
    }

    //学生选课
    public boolean removeCourse(Course course) {
        boolean flag = false;
        for (int i = 0; i < this.StudentCourse.length; i++) {
            if (StudentCourse[i] == course) {
                StudentCourse[i] = null;
                flag = true;
                break;
            }
        }
        return flag;
    }//学生退课
    public void displayCourse(){
        System.out.print("学生"+this.Name+"所选课程为");
        for(Course c:StudentCourse){
            if(c!=null){
                System.out.println("\n "+c.getCourseID()+" "+c.getCourseName()+" "
                        +c.getClassroom()+" "+c.getTime()+" ");}}//打印课表
    }
}



